<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <script src="../dist/cnjm-practical.js"></script> -->
    <!-- <script src="https://cdn.jsdelivr.net/npm/cnjm-practical@1.0.2/dist/cnjm-practical.js"></script> -->
</head>

<body>
    <div class="app">点击</div>

    <script type="module">
        // <script>
        import $practical from '../src/index.js';

        // PSet
        let  {PSet} = $practical;
        let arr1 = new Set([1,2,3,4,5,6,7,8,9])
        let arr2 = new Set([1,2,3,7,8,9,10])
        let arr3 = new Set([4,5,6])
        const pset = new PSet();

        // union 返回两个或更多集合的并集
        // console.log([...pset.union(arr2,arr3)]);// [1, 2, 3, 7, 8, 9, 10, 4, 5, 6]
        
        // intersection 返回两个或更多集合的交集
        // console.log(pset.intersection(arr1,arr2));// Set(6) {1, 2, 3, 7, 8, 9}
        
        // difference 返回两个集合的差集 a - b;
        // console.log(pset.difference(arr1,arr2));
        
        // symmetricDifference 返回两个集合的对称差集
        // console.log(pset.symmetricDifference(arr1,arr2));// Set(4) {4, 5, 6, 10}

        // cartesianProduct 返回两个集合（数组对形式）的笛卡儿积
        // 必须返回数组集合，因为笛卡儿积可能包含相同值的对
        // console.log(pset.cartesianProduct(arr2,arr3));// Set(21) {Array(2), Array(2), Array(2), Array(2), Array(2), …}

        // powerSet 返回一个集合的幂集
        // console.log(pset.powerSet(arr3));
        // 0: Set(0)
        // value: Set(0) {}
        // 1: Set(1)
        // value: Set(1) {4}
        // 2: Set(1)
        // value: Set(1) {5}
        // 3: Set(2)
        // value: Set(2) {4, 5}
        // 4: Set(1)
        // value: Set(1) {6}
        // 5: Set(2)
        // value: Set(2) {4, 6}
        // 6: Set(2)
        // value: Set(2) {5, 6}
        // 7: Set(3)
        // value: Set(3) {4, 5, 6}


        //url
        let  {url} = $practical;
        // console.log(url.paramToObj("http://cdn.jsdelivr.net/npm/cnjm-practical@1.0.2/dist/index.html?a=1&b=2"))

        // util
        let  {copy,uaCheck,cloneDeep,regToYuan,regToFen,getByteLen} = $practical;

        // console.log(getByteLen('哈'))
        // console.log(regToYuan(0.2,1000));//0.002
        // console.log(regToYuan(5000.22));//50
        // console.log(regToFen('300.25',1000));
        // console.log(regToFen(300.25,100));

        // let test = {
        //     a:'123',
        //     b:123,
        //     c:[{d:'hh'}],
        //     e:function(num){return num},
        //     f:null,
        //     g:undefined,
        //     h:new Date(),
        //     i:{j:{k:{l:"mn"}}}
        // }
        // let out = cloneDeep(test);
        // test.a = '321';
        // test.b = '321';
        // test.c = [{d:'gg'}];
        // test.e = function(num){return num+1};
        // test.f = undefined;
        // test.g = null;
        // test.i = {};
        // test.h = new Date(1629097648000);
        // console.log(out.e(555),Date.parse(out.h));
        // console.log(test.e(555),Date.parse(test.h));

        // console.log(uaCheck("Windows"))
        // console.log(uaCheck("MacOS"))
        // console.log(uaCheck("Linux"))
        // console.log(uaCheck("Android"))
        // console.log(uaCheck("IOS"))
        // console.log(uaCheck("Mobile"))
        // console.log(uaCheck("Tablet"))
        // console.log(uaCheck("WeChat"))
        // console.log(uaCheck("IPhone"))
        // console.log(uaCheck("IPad"))

        // let oApp = document.querySelector(".app");
        
        // oApp.ondblclick = function(){
        //     console.log('click')
        //     copy("testCopy",".app");
        // }
        


        // storage  get相关返回值，set返回布尔值，以此判断是否成功
        let { get, getAll,set,setAll,clear ,que} = $practical.storage;
        // console.log(set("str","str_value"));
        // console.log(set("arr",[{obj_key:123456},[1,2,3]])); //支持object、string、array
        
        // set("account",[{key1:123456,a:"aaa"},{key2:"654321"},{key3:"9999"}]); //支持object、string、array
            
        // 设置account数组下的key1的值,如果key已存在，则覆盖。注意：仅覆盖该key的值，其他属性不会改变
        //插入方式默认原位置覆盖,有三种方式可选original:默认值，unshift:插到开头，push:插到尾部。
        // que({
        //     method: "set",
        //     key: "account",
        //     subKey: "key2",
        //     value: { text: "value可以是一个json" },
        //     position: "unshift",
        // })
        // console.log(que({method:"get",key:"account",subKey:"key2",value:"555555"}));
        // console.log(que({method:"",key:"account",subKey:"key1",value:"555555",position:""}));
        // console.log(que({method:"get",key:"account",subKey:"key2"}));// 获取account数组下的key1的值
        // console.log(que({method:"clear",key:"account",subKey:"key2"}));// 删除account数组下的key1 及其值

        // console.log(get("account","key1"));
        // console.log(get("account","key2"));
        // console.log(get("account","key3"));

        // console.log(setAll({key1:"string",key2:{c:1321},key3:[1,2]}));//传入一个object，将分别对key ，value值进行存储，value 支持object、string、array
        // console.log(getAll());// 获取当前域的所有存储内容，并返回一个包含所有key:value的object，value 支持object、string、array的序列化字符串
        
        // clear();//清空所有，接受一个字符串key可以指定清除

        let { format, diff,storage } = $practical.date;
        //diff
        
        // console.log(diff(1609434061000,new Date(), 'Y'));//1
        // console.log(diff(1609434061000,new Date(), 'D'));//224
        // console.log(diff(1609434061000,new Date(), '',(num) => Math.ceil(num)));//19323249254

        //format
        // console.log(format(new Date(), "YYYY-MM-D:HH:mm:ss", true));
        // console.log(format(new Date(), "A-YYYY-MM-DD:hh"));
        // console.log(format(1609434061000, "YY年MM月DD日hh时mm分ss秒SSS毫秒"));
        // console.log(format("2021-08-08", "YY年MM月DD日hh时mm分ss秒SSS毫秒"));
    </script>
</body>

</html>